package com.caotv.wkreport.converter;

import java.util.Date;
import java.util.Map;
import java.text.*;

import org.apache.struts2.util.StrutsTypeConverter;

public class DateConverter extends StrutsTypeConverter {

	@Override
	public Object convertFromString(Map context, String[] values, Class clazz) {
		try {
			DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
			Date date = df.parse(values[0]);
			return date;
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return null;
	}

	@Override
	public String convertToString(Map context, Object value) {
		DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
		return df.format(value);
	}

}
